package biz.obake.team.touchprotector.fingerprint;

import android.app.Activity;
import android.content.Intent;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Build;
import android.os.CancellationSignal;
import android.os.Handler;

public class FingerprintActivity extends Activity {
    /* access modifiers changed from: private */

    /* renamed from: b  reason: collision with root package name */
    public static b f1703b;
    /* access modifiers changed from: private */

    /* renamed from: c  reason: collision with root package name */
    public static CancellationSignal f1704c;

    class a extends FingerprintManager.AuthenticationCallback {
        a() {
        }

        public void onAuthenticationError(int i, CharSequence charSequence) {
            FingerprintActivity.f1703b.d(i, charSequence);
            CancellationSignal unused = FingerprintActivity.f1704c = null;
            FingerprintActivity.this.finish();
        }

        public void onAuthenticationFailed() {
            FingerprintActivity.f1703b.e();
        }

        public void onAuthenticationHelp(int i, CharSequence charSequence) {
            FingerprintActivity.f1703b.c(i, charSequence);
        }

        public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult authenticationResult) {
            FingerprintActivity.f1703b.b();
            CancellationSignal unused = FingerprintActivity.f1704c = null;
            FingerprintActivity.this.finish();
        }
    }

    public interface b {
        void a();

        void b();

        void c(int i, CharSequence charSequence);

        void d(int i, CharSequence charSequence);

        void e();
    }

    /* JADX WARNING: Code restructure failed: missing block: B:3:0x0008, code lost:
        r0 = (android.hardware.fingerprint.FingerprintManager) biz.obake.team.android.a.a().getSystemService("fingerprint");
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static boolean c() {
        /*
            int r0 = android.os.Build.VERSION.SDK_INT
            r1 = 0
            r2 = 23
            if (r0 >= r2) goto L_0x0008
            return r1
        L_0x0008:
            biz.obake.team.android.a r0 = biz.obake.team.android.a.a()
            java.lang.String r2 = "fingerprint"
            java.lang.Object r0 = r0.getSystemService(r2)
            android.hardware.fingerprint.FingerprintManager r0 = (android.hardware.fingerprint.FingerprintManager) r0
            if (r0 == 0) goto L_0x0023
            boolean r2 = r0.isHardwareDetected()
            if (r2 == 0) goto L_0x0023
            boolean r0 = r0.hasEnrolledFingerprints()
            if (r0 == 0) goto L_0x0023
            r1 = 1
        L_0x0023:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: biz.obake.team.touchprotector.fingerprint.FingerprintActivity.c():boolean");
    }

    /* JADX WARNING: Code restructure failed: missing block: B:3:0x0008, code lost:
        r0 = (android.hardware.fingerprint.FingerprintManager) biz.obake.team.android.a.a().getSystemService("fingerprint");
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static boolean d() {
        /*
            int r0 = android.os.Build.VERSION.SDK_INT
            r1 = 0
            r2 = 23
            if (r0 >= r2) goto L_0x0008
            return r1
        L_0x0008:
            biz.obake.team.android.a r0 = biz.obake.team.android.a.a()
            java.lang.String r2 = "fingerprint"
            java.lang.Object r0 = r0.getSystemService(r2)
            android.hardware.fingerprint.FingerprintManager r0 = (android.hardware.fingerprint.FingerprintManager) r0
            if (r0 == 0) goto L_0x001d
            boolean r0 = r0.isHardwareDetected()
            if (r0 == 0) goto L_0x001d
            r1 = 1
        L_0x001d:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: biz.obake.team.touchprotector.fingerprint.FingerprintActivity.d():boolean");
    }

    public static void e(b bVar) {
        f1703b = bVar;
        if (f1704c == null) {
            f1704c = new CancellationSignal();
        }
        biz.obake.team.android.a a2 = biz.obake.team.android.a.a();
        Intent intent = new Intent(a2, FingerprintActivity.class);
        intent.setFlags(268435456);
        a2.startActivity(intent);
    }

    private boolean f() {
        FingerprintManager fingerprintManager;
        if (Build.VERSION.SDK_INT < 23 || (fingerprintManager = (FingerprintManager) getSystemService("fingerprint")) == null) {
            return false;
        }
        fingerprintManager.authenticate((FingerprintManager.CryptoObject) null, f1704c, 0, new a(), (Handler) null);
        b bVar = f1703b;
        if (bVar == null) {
            return true;
        }
        bVar.a();
        return true;
    }

    public static void g() {
        CancellationSignal cancellationSignal = f1704c;
        if (cancellationSignal != null) {
            cancellationSignal.cancel();
        }
    }

    public void finish() {
        super.finish();
        overridePendingTransition(0, 0);
    }

    /* access modifiers changed from: protected */
    public void onResume() {
        super.onResume();
        if (f1704c.isCanceled()) {
            f1704c = null;
            finish();
        } else if (!f()) {
            f1704c = null;
            finish();
        }
    }
}
